package cn.panda.edu.service.impl;

import cn.panda.edu.dao.MajorMapper;
import cn.panda.edu.model.Major;
import cn.panda.edu.service.MajorService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class MajorServiceImpl implements MajorService {

	@Autowired
	private MajorMapper majorMapper;
	
	@Override
	public int deleteByPrimaryKey(Integer majorId) {
		// TODO Auto-generated method stub
		return majorMapper.deleteByPrimaryKey(majorId);
	}

	@Override
	public int insert(Major record) {
		// TODO Auto-generated method stub
		return majorMapper.insert(record);
	}

	@Override
	public int insertSelective(Major record) {
		// TODO Auto-generated method stub
		return majorMapper.insertSelective(record);
	}

	@Override
	public Major selectByPrimaryKey(Integer majorId) {
		// TODO Auto-generated method stub
		return majorMapper.selectByPrimaryKey(majorId);
	}

	@Override
	public int updateByPrimaryKeySelective(Major record) {
		// TODO Auto-generated method stub
		return majorMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKeyWithBLOBs(Major record) {
		// TODO Auto-generated method stub
		return majorMapper.updateByPrimaryKeyWithBLOBs(record);
	}

	@Override
	public int updateByPrimaryKey(Major record) {
		// TODO Auto-generated method stub
		return majorMapper.updateByPrimaryKey(record);
	}

	@Override
	public PageInfo<Major> selectByPageAndSelective(Integer majorId, int pageIndex, int pageSize) {
		// TODO Auto-generated method stub
		Map<String, Object> map = new HashMap<>();
		map.put("majorId", majorId);
		//map.put("majorName", majorName);
		PageHelper.startPage(pageIndex, pageSize);
		List<Major> mList = majorMapper.selectByIdAndName(map);
		PageInfo<Major> pageInfo = new PageInfo<>(mList);
		return pageInfo;
	}

	@Override
	public List<Major> selectAll() {
		// TODO Auto-generated method stub
		return majorMapper.selectAll();
	}

}
